import { Controller, Get, Render } from '@nestjs/common';
import { ArticleService } from './article.service';

@Controller('demo-ejs')
export class DemoEjsController {
  constructor(private readonly articleService: ArticleService) {}

  @Get()
  @Render('demo-ejs.html')
  async getDemoPage() {
    const articles = await this.articleService.findAll();

    return {
      title: 'EJS 演示页面',
      showMessage: true,
      items: [{ name: '项目 1' }, { name: '项目 2' }, { name: '项目 3' }],
      users: [
        { id: 1, name: '张三', email: 'zhangsan@example.com', role: '管理员' },
        { id: 2, name: '李四', email: 'lisi@example.com', role: '用户' },
        { id: 3, name: '王五', email: 'wangwu@example.com', role: '用户' },
      ],
      articles: articles,
    };
  }
}
